from kivy.uix.label import Label

class WordWrapLabel(Label):

    def __init__(self, **kargs):
        Label.__init__(self, **kargs)
        self.bind(parent=self.parent_handler)
        
    def parent_handler(self, instance, value):
        if instance is not None:
            instance.bind(size=self.parent_size_handler)

    def parent_size_handler(self, instance, value):
        w = value[0]
        if self.size_hint is not None:
            if self.size_hint['x'] is not None:
                w *= self.size_hint['x']
        self.text_size = (w, None)
